package fun.sboy.util;

import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;

public class IconUtil {


    public static Image load(String name, int width, int height, int hints) {
        String file = String.format("/iconfont/%s.png", name);
        InputStream imageStream = IconUtil.class.getResourceAsStream(file);
        try {
            BufferedImage image = ImageIO.read(imageStream);
            Image image2 = image.getScaledInstance(width, height, hints);
            return image2;
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public static Image loadSmall(String name) {
        String file = String.format("/iconfont/%s.png", name);
        InputStream imageStream = IconUtil.class.getResourceAsStream(file);
        try {
            BufferedImage image = ImageIO.read(imageStream);
            Image image2 = image.getScaledInstance(30, 30, 1);
            return image2;
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
